home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / networking / 3216 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  16.8 KB

  1. Path: cs.uwa.edu.au!jasonb
  2. From: jasonb@cs.uwa.edu.au (Jason S Birch)
  3. Newsgroups: comp.sys.amiga.networking
  4. Subject: Re: Announce: AWeb 1.0 released!
  5. Date: 30 Mar 96 09:53:39 GMT
  6. Organization: The University of Western Australia
  7. Message-ID: <jasonb.828179619@cs.uwa.edu.au>
  8. References: <4iva78$5pa@news.xs4all.nl> <4j1f6e$984@news.uni-c.dk> <jasonb.827822336@cs.uwa.edu.au> <4j8o6r$9vj@serpens.rhein.de> <jasonb.827896888@cs.uwa.edu.au> <4jaue8$jh4@serpens.rhein.de> <jasonb.827996764@cs.uwa.edu.au> <4je3qj$kk@serpens.rhein.de> <jasonb.828076494@cs.uwa.edu.au> <4jgdfr$8f4@serpens.rhein.de> <jasonb.828104646@cs.uwa.edu.au> <4jh986$a5o@serpens.rhein.de>
  9. NNTP-Posting-Host: decadence.cs.uwa.oz.au
  10. X-Newsreader: NN version 6.5.0 #3 (NOV)
  11.  
  12.  
  13. mlelstv@serpens.rhein.de (Michael van Elst) writes:
  14. >jasonb@cs.uwa.edu.au (Jason S Birch) writes:
  15.  
  16. >That's the key. CPU intensive stuff is _not_ lower. You don't want
  17. >to manually change the priorities and you do not want every program
  18. >to change its own priorities.
  19.  
  20. You *do* want to manually change priorities if the long-running CPU
  21. intensive process is going to affect interactive performance
  22. needlessly. This applies to text editors, shells, *anything* -- not
  23. just MUI programs. You run a few CPU intensive processes at priority
  24. 0, then try typing into your text editor. Unless your A3000 is a lot
  25. faster than my A4000, it will become sluggish. Now run them at -1.
  26. Your text editor responds as if they weren't there, and they don't
  27. actually get *less* CPU in the long term because of it -- the text
  28. editor simply gets the cycles it would have had anyway, except it gets
  29. them immediately it wants them.
  30.  
  31. I seem to recall that Exec's absolute scheduling based soley on
  32. priorities has long been an advantage boasted about by Amiga advocates
  33. -- lower the priority of the CPU hog and it only gets cycles that
  34. would have gone unused anyway, keeping the machine responsive, unlike
  35. Unix or NT. It's hardly going to be much of an advantage if we're all
  36. too afraid to move anything below 0, now, is it?
  37.  
  38. >The default priority of a process is zero.
  39.  
  40. Yes. And for a long time now, we've been able to modify it.
  41. ChangeTaskPri and just about every monitor ever written for the Amiga
  42. allows you to change priorities. It's there for a reason.
  43.  
  44. >So provide timely feedback as AmigaOS did it all the time: by using
  45. >input.device. It exists, it is the standard, it works well, you don't
  46. >need a scheduler that outguesses a programs intention.
  47.  
  48. It also means that every class of MUI would be running at pri 20 by
  49. default unless the programmer explicitely did otherwise. Which would
  50. you prefer: MUI apps running the bulk of their code at pri 20 because
  51. the programmer didn't know any better, or MUI apps running the bulk of
  52. their code at pri 0? Which is more friendly to the rest of the system?
  53. In one case, you basically kill every other app on the computer if the
  54. programmer messes up. In the other, the particular app isn't very
  55. responsive if the programmer messes up. I know which I'd prefer.
  56.  
  57. The AmigaGuide datatype is a good example of what can happen when you
  58. adopt the former scheme. I believe ClassAct also does this, but makes
  59. it easy for the programmer to put parts of the custom class on the
  60. application's context if they feel it would take too long.
  61.  
  62. >>Another one is wanting to have a uniform notification scheme which can
  63. >>work uniformly on any attribute of any object. Running your GUI event
  64. >>handling code on two separate tasks, one at pri 20 and one at the usual
  65. >>pri, would make this very messy.
  66.  
  67. >This isn't more difficult than other code that needs several tasks.
  68.  
  69. It is if you want to keep notification working on everything and you
  70. don't want the programmer to have to deal with the internals of your
  71. OO system (BOOPSI).
  72.  
  73. >And if you use MUI you have to do the same. Wether your code spawns
  74. >that process or you use the existing input.device process.
  75.  
  76. No -- because the OO system *itself* doesn't run at different
  77. priorities. Within a custom class, the OO mechanism is still running on
  78. the same context as the rest of the classes. Any method you call, any
  79. attribute you set, is all still on the same context. Internal functions
  80. to your class can be running on different contexts, but that has
  81. nothing to do with your OO mechanism. Within those other contexts, you
  82. can't call methods and set attributes of other objects directly. It
  83. would get very messy to implement if you could, and you would need to
  84. implement it that way if you didn't want the whole thing running at
  85. pri 20 by default.
  86.  
  87. >>So MUI does it all on the usual
  88. >>priority task's context, which makes MUI simpler but means the
  89. >>programmer has to be aware of the issues of GUI responsiveness and
  90. >>ensure his event handling loop is always ready and waiting.
  91.  
  92. >Which is more difficult and interferes with more programs than simple
  93. >semaphore locking of data structures.
  94.  
  95. Why is it more difficult? The subtasks are completely under your
  96. control, and aren't interacting with the other tasks in unknown ways
  97. because they only interact through *your* mechanisms, when you've
  98. explicitely asked them to.
  99.  
  100. >>You even have some things -- like the
  101. >>AmigaGuide datatype laying out AmigaGuide documents -- running at pri
  102. >>20 when they really shouldn't be.
  103.  
  104. >Sure. I never said that existing BOOPSI gadgets are perfect but
  105. >datatypes already provide a method to offload expensive operations.
  106. >This is a function of the datatypes.library.
  107.  
  108. That's right -- the *programmer* is left the task of offloading
  109. expensive operations, with disasterous results if they don't. The
  110. worst that happens with MUI is individual applications that feel
  111. sluggish. A complex AmigaGuide document can stop my mouse pointer
  112. moving for a second or more.
  113.  
  114. >>Or, to put it another way -- you can lower the priority of tasks not
  115. >>directly communicating with the user.
  116.  
  117. >Again. That is something YOU have to do.
  118.  
  119. And something I always did, even before MUI and Executive came along.
  120. Applications running CPU intensive tasks at pri 0 have always been
  121. annoying, because they make the system sluggish -- but at least we've
  122. always been able to move them if necessary.
  123.  
  124. >Think about programs that do not do event handling. Something simple
  125. >as a compiler or anything written in straight ANSI C.
  126.  
  127. If they take long enough for you to want to do something else
  128. interactive in the meantime, think about using ChangeTaskPri, or Scout,
  129. or ARTM. Or use Executive, and let it happen automatically.
  130.  
  131. >>>With the standard Exec scheduler you can even allow it to run on
  132. >>>the same priority. 
  133.  
  134. >>But what do you gain from doing so?
  135.  
  136. >You do not need to write special code to keep MUI and Executive happy.
  137. >That's what it is.
  138.  
  139. Again. Sigh... This has nothing to do with MUI and Executive. Running
  140. CPU intensive processes at pri 0 *will* make the machine feel slower.
  141. You *will* notice the effect in your text editor. You *will* notice
  142. that, while a button still depresses instantly, the application takes
  143. longer to respond. Take advantage of the Amiga's multitasking and run
  144. a raytracer, AWeb, and a text editor all at pri 0, and you will start
  145. becoming frustrated while the other guy who's put the CPU intensive,
  146. non-interactive stuff at a lower priority doesn't even notice
  147. anything's happening, *at no real detriment to the CPU intensive
  148. tasks*!
  149.  
  150. >>Of course they don't. I'm not talking about changing AWeb so it won't
  151. >>"interfere" with MUI --
  152.  
  153. >Run a MUI program. Run another CPU-intensive program at the same
  154. >priority (i.e. 0: the default priority). Watch the MUI program to
  155. >become sluggish (if it isn't already).
  156.  
  157. Watch your text editor also become sluggish. Watch the computer become
  158. slow to respond to user input. Sure, the GadTools buttons may depress
  159. instantly, but it will be slower to respond and you'll notice this.
  160. Listviews will be slow to scroll. All of this is unnecessary, because
  161. it would all disappear if only the CPU intensive program was running
  162. at a lower priority.
  163.  
  164. I just did a simple test. I did an 'ls -l' of SD0:, which has four files
  165. in it. It took 0.5 seconds. I then ran two CPU intensive processes at
  166. the same priority. Just two. It took 4.0 seconds. Eight times longer.
  167. Why? Well, because the ls was doing I/O -- it kept waiting, voluntarily
  168. giving up the CPU before its quantum (4 VBLs) was up. Once it had
  169. given up the CPU, it didn't get it again until the two CPU intensive
  170. tasks had completely used their quantums, even though the packet it was
  171. waiting for had arrived -- it was at the same priority, so the other
  172. two tasks weren't pre-empted. So, it eventually gets the packet, and
  173. Wait()s for the next -- oops, there goes the CPU again. If it's only
  174. using, say, 1/4 of its timeslice before it waits again, it could easily
  175. be getting just 1/9th the CPU even though just three tasks are trying
  176. to use it. Giving up the CPU before your timeslice is up doesn't mean
  177. you can "save it up" for next time around, you lose it forever. This is
  178. why running interactive tasks at the same priority as CPU intensive
  179. tasks is such a bad idea, and can make them feel so drastically slower.
  180. Note that if the ls was running at just one level above the other two
  181. tasks, then as soon as the packet it was waiting for arrived, it would
  182. process it. The other two tasks would still get the CPU whenever the ls
  183. waited (which is quite often the case with tasks doing I/O, or
  184. interactive tasks).
  185.  
  186. >>I'm talking about making AWeb *itself* more
  187. >>responsive,
  188.  
  189. >AWeb is responsive. If you run Executive at the same time it isn't.
  190.  
  191. It isn't responsive if (gasp) I run another CPU intensive task at
  192. priority 0, or if it's coping with many connections and image
  193. decompressions while I'm trying to scroll through a large document.
  194. If the CPU intensive tasks it spawns ran at a lower priority, it would
  195. be. (This is without running Executive, BTW.)
  196.  
  197. >>In case it isn't obvious -- in order for a MUI program to remain
  198. >>responsive, all that's required is that no CPU intensive tasks be
  199. >>competing with it for the CPU at the same priority.
  200.  
  201. >So none of the standard programs is allowed to run, because these
  202. >programs surely do not change task priorities to keep MUI happy.
  203.  
  204. Many programs (eg. Real3D, IBrowse) spawn subtasks to do CPU intensive
  205. tasks. (Note that *only* CPU intensive programs need do this, other
  206. "standard programs" make no difference.) Some even allow the user to
  207. set their priorities within the program (eg. IBrowse). Those that don't
  208. can be manually set by the user, or automatically changed by Executive.
  209. This is *not* just about "keeping MUI happy", much as you would like it
  210. to be so. This is about making an 'ls' finish as fast as it could.
  211. About your text editor responding to your typing, or scrolling your
  212. document, when you want it to. Your CPU intensive task doesn't suffer
  213. from being at a low priority, but your interactive tasks sure as hell
  214. do if it isn't.
  215.  
  216. >>Of course it doesn't. Over a long period of time they get the same
  217. >>amount of CPU (all else being equal), but in one second they can get
  218. >>vastly different amounts.
  219.  
  220. >Which means that it is pretty unusuable.
  221.  
  222. Of course not. I don't care if two Real3D drawtasks are exchanging the
  223. CPU every second or every 1/50th of a second. It makes no difference
  224. to the actual completion time (actually, the longer quantums might
  225. actually make it faster because eg. the cache remains useful for
  226. longer). All I care is that they're running at a lower priority than
  227. my editor and anything else interactive I want to do -- otherwise,
  228. like the 'ls' example above, the interactive stuff gets *very* slow.
  229.  
  230. >>get one seconds' worth of CPU, but they would've got it in bursts of
  231. >>about 0.05 seconds at a time.
  232.  
  233. >And that's what we want to create the illusion of concurrency:
  234. >multitasking.
  235.  
  236. "CPU intensive" generally refers to things that take many seconds and
  237. use the CPU for their entire quantum. Tasks which are interactive will
  238. have a higher priority, will give up the CPU often, and will still
  239. appear to be running concurrently. Higher priority tasks, which under
  240. Executive are usually those that are event-driven or I/O bound, still
  241. pre-empt those CPU intensive ones. Tasks which are currently receiving
  242. focus from the user will also be raised even higher, to ensure they
  243. are responsive. Any special cases which don't fit into the above
  244. categories can be explicitely catered for in the preferences.
  245.  
  246. Executive doesn't do *anything* that a user couldn't do (if they were
  247. fast enough). It doesn't change Exec's scheduler, it doesn't make
  248. AmigaOS non-pre-emptive. It doesn't even change priorities, if you
  249. don't want it to.
  250.  
  251. >>I would make an entry for them in Executive's preferences.
  252.  
  253. >So another thing the user has to change to keep Executive happy.
  254.  
  255. Executive couldn't care less. It's to keep the user happy. Are you
  256. happy waiting 4 seconds for an 'ls' that *could* have been finished in
  257. 0.5? Just because *two* other tasks are running?
  258.  
  259. >>As I said, nothing I've said has anything to do with "making MUI
  260. >>happy".
  261.  
  262. >Sure. To make MUI happy you have to run CPU intensive processes
  263. >at priorities below 0.
  264.  
  265. And your editor, and your shell, and your C compiler (typically lots of
  266. I/O), and the listviews of your GadTools programs... Just saying MUI is
  267. the only one affected over and over doesn't make it any more true. And
  268. again, MUI couldn't give a damn. It's the user I'm thinking of.
  269.  
  270. >>Given he's already spawned off network transferring and image decoding
  271. >>onto subtasks, is it really such a terrible thing to want page layout
  272. >>there as well?
  273.  
  274. >If page layout is fast enough there is no need for just another task.
  275.  
  276. 157 seconds for one page (the 600K page I was referring to earlier,
  277. showing our site's usage statistics which I check now and then) is
  278. quite a long time, so I suppose you're agreeing now that there *is* a
  279. need for just another task? Or perhaps you think we should only ever
  280. look at small pages so the delay doesn't get too long? Sounds like a
  281. real good, all-purpose solution.
  282.  
  283. If I click "<-", it still takes 18 seconds before the (small) previous
  284. page is shown again, and 119 seconds before the big page is displayed
  285. again if I then click "->", and I *can't* stop it if I change my mind.
  286. (Interesting tidbit -- IBrowse completely displays the same page in 107
  287. seconds, including all transferring; AWeb takes 119 seconds just to
  288. display it from the cache, and it's not even using the disk to store
  289. it.) I have to wait for it to finish (again, this is without
  290. Executive), and it doesn't even display the HTML progressively when
  291. using "<-" or "->" like it does while transferring the data across the
  292. network. Also, presumeably his page layout code -- since it is also
  293. doing event handling when loading it across the network the first time,
  294. which still works albeit sluggishly -- must keep stopping to process
  295. events. If it was in a separate task it should actually be *easier*,
  296. because it separates the code into two distinct types.
  297.  
  298. BTW, I've solved the problems it was having with Executive (not
  299. processing input at all while loading the page) by making an entry for
  300. it in the preferences. I'd still like a separate task, though, so I
  301. can prioritize them rather than making AWeb become sluggish under a
  302. heavy load (which IBrowse doesn't).
  303.  
  304. >Anyway, this is not a problem unless Executive tries to outguess the
  305. >programs.
  306.  
  307. Hmm... Just about every point I've made about why wanting the CPU
  308. intensive code running on a separate thread at a lower priority than
  309. the main event-handling task is completely independent of both 
  310. Executive and MUI, yet all you ever do is blame Executive and MUI. It
  311. has nothing to do with them! In fact, Executive partially alleviates
  312. the problem, because using it I can at least set AWeb and all its
  313. child tasks at a low priority so they won't make the rest of the apps
  314. (like my text editor) sluggish when doing a lot of work, just like
  315. *any* CPU intensive process running at priority 0 will do. *You* might
  316. be happy merely having buttons depress instantly, but *I* want the
  317. computer to respond to my actions instantly when it can, and running a
  318. CPU intensive process at a low priority enables that.
  319.  
  320. >>Well, even before I ran Executive, I always set priorities manually to
  321. >>ensure processes like my editor ran higher than processes like Real3D.
  322.  
  323. >If you work in a shell, do you set the priorities for every command
  324. >you start ?
  325.  
  326. It depends on how long it's going to take. If I'm going to be waiting
  327. at the prompt for it to return, no, there'd be no point. If it was a C
  328. compile that was going to take 20 minutes with the optimizer, of course
  329. I would. Same with Real3D -- doing edit-compile-run cycles with a
  330. week-long raytrace running in the background at the same priority is no
  331. fun. Run it at a lower priority and you don't even know it's there.
  332. This has long been one of the strengths of the Amiga.
  333.  
  334. >                                Michael van Elst
  335. >Internet: mlelstv@serpens.rhein.de
  336.  
  337. -- 
  338. Jason S Birch                        ,-_|\ email: jasonb@cs.uwa.edu.au
  339. Department of Computer Science      /     \ Tel (work): +61 9 380 1840
  340. The University of Western Australia *_.-._/ Fax (work): +61 9 380 1089
  341. Nedlands  W. Australia  6907             v  Tel (home): +61 9 386 8630
  342.